﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Galoap
{
    public class Category
    {

        public string SingularCategoryName;
        public string PluralCategoryName;
        protected string[] CategoryAttributes;

        virtual public string GetRandmAttribute()
        {
            Random _r = new Random();
            return CategoryAttributes[_r.Next(CategoryAttributes.Length -1)];
        }

        virtual public string GetAttribute(int index)
        {
            if (index < CategoryAttributes.Length)
                return CategoryAttributes[index];
            else throw new InvalidOperationException("Index out of range.");
        }

        virtual public string GetAttribute(string attribute)
        {
            attribute = attribute.ToLower();
            foreach (string s in CategoryAttributes)
                if (s.Equals(attribute))
                    return s;
            throw new InvalidOperationException("Attribute inexistant in category attribute table.");
        }

        virtual public bool IsDefinedInCategory(string attribute)
        {
            attribute = attribute.ToLower();
            foreach (string s in CategoryAttributes)
                if (s.Equals(attribute))
                    return true;
            return false;
        }
    }
}
